<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport"/>
    <link rel="stylesheet" href="css/amazeui.min.css">
    <link rel="stylesheet" href="css/animate.min.css">
    <link rel="stylesheet" href="css/style.css">
    <title>个人信息</title>
</head>
<body>
<header data-am-widget="header"
        class="am-header am-header-default" style="background-color: #FF856E;">
    <div class="am-header-left am-header-nav">
        <a href="javascript:history.go(-1);" style="float: left">
            <i class="am-icon-chevron-left" style="font-size: 22px;color: white;"></i>
        </a>
        <span style="font-size: 16px;color:white; ">修改资料</span>
    </div>


    <div class="am-header-right am-header-nav">
        <a href="updateInfo.html" style="color: white;"></a>
    </div>
</header>

<div class="am-list-news am-list-news-default" data-am-widget="list_news" style="margin: 5% auto;background-color: white;">
    <div class="am-list-news-bd" >
        <ul class="am-list" style="padding-left:5%;padding-right: 5%;">
            <li style="border-top: 0;" class="am-g am-list-item-dated">
               <a class="am-list-item-hd">电话:</a>
               <span class="am-list-date am-u-sm-10">
                   <input type="text" id="phone" class="phone" value="">
               </span>
            </li>
            <li style="" class="am-g am-list-item-dated" >
                <a class="am-list-item-hd">地址:</a>
                <span class="am-list-date am-u-sm-10">
                    <input type="text" id="address" class="address" value="">
                </span>
            </li>
        </ul>
    </div>
</div>

<div class="am-form-group am-u-sm-12" id="btnUpdateInfo">
</div>

<script src="js/jquery.min.js"></script>
<script src="js/main.js"></script>
</body>
<script>
    $(function () {
        getUserInfo();

        const phone = $(".phone").val();
        const address = $(".address").val();

        $("#phone").bind('input propertychange', function () {
            let phoneNew = $(".phone").val();
            if (phoneNew != phone) {
                $("#updateBtn").attr("disabled",false);
            }else {
                $("#updateBtn").attr("disabled",true);
            }
        });

        $("#address").bind('input propertychange', function () {
            let addressNew = $(".address").val();
            if (addressNew != phone) {
                $("#updateBtn").attr("disabled",false);
            }else {
                $("#updateBtn").attr("disabled",true);
            }
        })


        $("#updateBtn").click(function () {
            let phoneNew = $(".phone").val();
            let addressNew = $(".address").val();
            const msg = updateInformation(phoneNew, addressNew);
            if (msg == "success") {
                window.location.href = "javascript:history.go(-1);"
            }
        })
    })

</script>
</html>